/* 
 * ReqHandler.java
 * 
 * @author david
 */
package org.puresilk.android.net.services;

import org.puresilk.android.net.HttpException;
import org.puresilk.android.net.HttpHandler;
import org.puresilk.android.net.HttpResponse;

/**
 * Class to provide callback structure for Web call
 * for services.
 */
class ReqHandler extends HttpHandler {
	/**
	 * 
	 */
	private final ActionService actionService;

	/**
	 * @param actionSubmissionService
	 */
	ReqHandler(ActionService actsub) {
		actionService = actsub;
	}

	private String url = null;
	private String data = null;
	
	// getters and setters
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}

	public String getData() {
		return data;
	}
	public void setData(String data) {
		this.data = data;
	}

	// Handler callbacks
	/**
	 * Houston, we have a problem...
	 */
	@Override
	public void onResponseError(HttpException arg0) {
		// log it
		
		// alert UI
		actionService.notifications("RPC Error");
	}

	/**
	 * No problems encountered in transit
	 */
	@Override
	public void onResponseReady(HttpResponse resp) {
		actionService.notifications(String.format("Msg Processed: %1$s",resp.getResultMsg()),ActionService.STATUS_ALERT);
	}
	
	// -- Not Implemented --
	@Override
	public void onRequestStart() { /* pass */}

	@Override
	public void onResponseProgress(String arg0) { /* pass */}
	@Override
	public void onWriteProgress(int bytesWritten) {/* pass */}

}